package com.example.mybatisdemo.controller;

import com.example.mybatisdemo.domain.returns.RespEntity;
import com.example.mybatisdemo.service.impl.FtpService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/ftp")
public class FtpController {
    @Resource
    private FtpService ftpService;

    @PostMapping("/uoload")
    public RespEntity uploadFile(@RequestParam("file")MultipartFile file) throws Exception {
        String remotePath = "/test/"+ file.getOriginalFilename();
        ftpService.uploadFile(remotePath,file);
        return RespEntity.success(remotePath);
    }
}
